package ejb.dao;

import ejb.entities.Event;
import ejb.entities.User;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;

@Stateless
public class EventDAO extends GenericDAO<Event>{
    
    	public EventDAO() {
		super(Event.class);
	}
        
        public Event findEventById(int idEvent) {
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("idEvent", idEvent);
		String query = "select u from Event u where u.idEvent = :idEvent";
		return super.findOneResult(query, parameters);
	}
        
         public List<Event> findEventByCreator(User us) {
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("user", us);
		String query = "select u from Event u where u.creator = :user";
		return super.findManyResult(query, parameters);
	}         
                   
}
